// 
//  index.js
//  <project>
//  
//  Created by lenovo on 2018-03-21.
//  Copyright 2018 lenovo. All rights reserved.
// 

var reg = /^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/;
$('form').submit(function(){
	var data= {
		tel:$('#tel').val(),
		city:$('#city').val(),
		date:$('#date').val()
	}
	if(data.city == ''){
        alert('请输入所在城市');
        return;
    }
    if(!reg.test(data.tel)){
        alert('请输入正确的手机号');
        return;
    }
	return false
	 $.ajax({
        type: 'POST',
        url: 'http://admin.heyizhizao.com/channel/addFactory',
        contentType: 'application/json; charset=utf-8',
        headers: {
            'Accept': 'application/json; charset=utf-8'
        },
        data: JSON.stringify(data),
        success: function (res) {
           if(res.stateCode == 100){
               $('#city').val('');
               $('#tel').val('');
               $('#date').val()
           }else{
               alert(res.message)
           }
        },
        error: function (err) {
            alert(err.message)
        }
    });
})

laydate.render({
  elem: '#date' //指定元素
});
var tablist =[
	{
		id:'0',
		name:'婚纱',
		imglist:[
			{
				url:"img/home-7.jpg",
				title:"2018抹胸性感风——《微风》",
			},
			{
				url:"img/home-8.jpg",
				title:"2018皇室宫廷风——《邂逅》",
			},
			{
				url:"img/home-9.jpg",
				title:"2018皇室宫廷风——《星空》",
			},
		]
	},
	{
		id:'1',
		name:'礼服',
		imglist:[
			{
				url:"img/home-3.jpg",
				title:"礼服-抹胸性感风——《微风》",
			},
			{
				url:"img/home-4.jpg",
				title:"礼服-皇室宫廷风——《邂逅》",
			},
			{
				url:"img/home-5.jpg",
				title:"礼服-皇室宫廷风——《星空》",
			},
		]
	},
	{
		id:'2',
		name:'秀禾',
		imglist:[
			{
				url:"img/home-19.jpg",
				title:"秀禾-抹胸性感风——《微风》",
			},
			{
				url:"img/home-20.jpg",
				title:"秀禾-皇室宫廷风——《邂逅》",
			},
			{
				url:"img/home-21.jpg",
				title:"秀禾-皇室宫廷风——《星空》",
			},
		]
	},
]
var TabHtml = "";
for(var index in tablist){
	var tab = tablist[index];
	var tabberBoxHtml = "";
	if(index == 0){
		TabHtml = '<div class="home3-tabber check">' + tab.name + '</div>';
	}else{
		TabHtml = '<div class="home3-tabber">' + tab.name + '</div>';
	} 
	$('.home3-tab').append(TabHtml);
	$('.home3-tabBox').append('<div class="home3-tabberBox"></div>')
	if(tab.imglist.length > 0){
		for(var num in tab.imglist){
			var tabBox = tab.imglist[num];
			tabberBoxHtml += 	'<div class="home3-box">';
			tabberBoxHtml += 		'<img src="'+ tabBox.url +'"/>';
			tabberBoxHtml += 		'<p>' + tabBox.title + '</p>';
			tabberBoxHtml += 	'</div>';
		}
		$('.home3-tabberBox').eq(index).append(tabberBoxHtml);
	}
}

$('.home3-tab').append('<div class="line"></div>')
$(function(){
	$('.header-container a').removeClass('check');
	$('.home').addClass('check');
	$('.home3-tabber').click(function(){
		$(this).addClass('check').siblings('.home3-tabber').removeClass('check');
		var num = $(this).index();
		$('.home3-tabberBox').hide()
		$('.home3-tabberBox').eq(num).show();
		$('.line').offset({ left: $(this).offset().left })
	})
})
